package com.cosmoplat.xikai.business.domain;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableField;
import com.cosmoplat.xikai.common.enums.business.AlarmTypeEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @TableName base_alarm_record
 */
@Data
@ApiModel(value = "告警记录", description = "用于表示系统中的告警记录信息")
public class BaseAlarmRecord implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @ApiModelProperty(value = "主键", example = "1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 设备编码
     */
    @ApiModelProperty(value = "设备编码", example = "EQP001")
    private String equipmentCode;

    /**
     * 告警代码
     */
    @ApiModelProperty(value = "告警代码", example = "ALM001")
    private String alarmCode;
    /**
     * 告警名称
     */
    @ApiModelProperty(value = "告警名称", example = "告警")
    private String alarmName;

    /**
     * 告警类型  1：质量异常告警，2：缺料告警，3：物料错误告警
     */
    @ApiModelProperty(value = "告警类型 (1: 质量异常告警, 2: 缺料告警, 3: 物料错误告警)", example = "1")
    private Integer alarmType;


    @ApiModelProperty(value = "告警类型名称", example = "质量异常告警")
    @TableField(exist = false)
    private String alarmTypeName;

    /**
     * 告警内容
     */
    @ApiModelProperty(value = "告警内容", example = "设备出现质量问题")
    private String alarmContent;

    /**
     * 告警开始时间
     */
    @ApiModelProperty(value = "告警开始时间", example = "2025-01-01 09:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date alarmStartTime;

    /**
     * 告警结束时间
     */
    @ApiModelProperty(value = "告警结束时间", example = "2025-01-01 09:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date alarmEndTime;

    /**
     * 物料编号
     */
    @ApiModelProperty(value = "物料编号", example = "CODE001")
    private String materialCode;

    /**
     * 业务信息 （记录关联的业务信息）
     **/
    @ApiModelProperty(value = "业务信息", example = "业务信息")
    private String businessInfo;


    public String getAlarmTypeName() {
        return AlarmTypeEnum.getNameByCode(alarmType);
    }
}

